﻿

GO

/****** Object:  Table [dbo].[CMS_Game]    Script Date: 06/24/2012 00:52:12 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[CMS_Game](
	[IdGame] [int] IDENTITY(1,1) NOT NULL,
	[NameGame] [nvarchar](200) NOT NULL,
	[CateId] [int] NOT NULL,
	[Production] [nvarchar](200) NULL,
	[LinkGame] [nvarchar](200) NULL,
	[Avatar] [nvarchar](200) NULL,
	[CreatedOn] [datetime] NULL,
	[CreatedBy] [nvarchar](50) NULL,
	[Status] [int] NOT NULL,
	[ShowType] [int] NOT NULL,
	[Description] [nvarchar](1000) NULL,
	[Contents] [ntext] NULL,
 CONSTRAINT [PK_CMS_Game] PRIMARY KEY CLUSTERED 
(
	[IdGame] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Tên game' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'CMS_Game', @level2type=N'COLUMN',@level2name=N'NameGame'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Hãng sản xuất' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'CMS_Game', @level2type=N'COLUMN',@level2name=N'Production'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Đường link chơi game' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'CMS_Game', @level2type=N'COLUMN',@level2name=N'LinkGame'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Ảnh đại diện game' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'CMS_Game', @level2type=N'COLUMN',@level2name=N'Avatar'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Mô tả game' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'CMS_Game', @level2type=N'COLUMN',@level2name=N'Description'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Nội dung chi tiết game' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'CMS_Game', @level2type=N'COLUMN',@level2name=N'Contents'
GO

USE [epl.vn]
GO

/****** Object:  Table [dbo].[CMS_LiveMatch]    Script Date: 06/24/2012 00:52:12 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[CMS_LiveMatch](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Title] [nvarchar](200) NULL,
	[LinkLive] [ntext] NULL,
	[Avatar] [nvarchar](100) NULL,
 CONSTRAINT [PK_CMS_LiveMatch] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Tên trận đấu' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'CMS_LiveMatch', @level2type=N'COLUMN',@level2name=N'Title'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Link xem trận đấu' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'CMS_LiveMatch', @level2type=N'COLUMN',@level2name=N'LinkLive'
GO

ALTER TABLE [dbo].[CMS_Game] ADD  CONSTRAINT [DF_CMS_Game_CreatedOn]  DEFAULT (getdate()) FOR [CreatedOn]
GO

ALTER TABLE [dbo].[CMS_Game] ADD  CONSTRAINT [DF_CMS_Game_Status]  DEFAULT ((1)) FOR [Status]
GO

ALTER TABLE [dbo].[CMS_Game] ADD  CONSTRAINT [DF_CMS_Game_ShowType]  DEFAULT ((0)) FOR [ShowType]
GO



GO

/****** Object:  StoredProcedure [dbo].[CMS_LiveMatch_Select]    Script Date: 06/24/2012 00:50:32 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[CMS_LiveMatch_Select]
@Type INT,
@Para_1 NVARCHAR(100) = NULL,
@Para_2 NVARCHAR(100) = NULL
AS
BEGIN	
	IF(@Type = 1) 
		BEGIN
			SELECT  * 
			FROM	CMS_LiveMatch								
		END	
	IF(@Type = 2) 
		BEGIN
			SELECT * FROM CMS_LiveMatch
			WHERE Id = CAST(@Para_1 AS INT)						
		END		
			
END

GO

/****** Object:  StoredProcedure [dbo].[CMS_LiveMatch_Delete]    Script Date: 06/24/2012 00:50:32 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[CMS_LiveMatch_Delete]
(
	@Id int
)

AS

SET NOCOUNT ON

DELETE FROM [CMS_LiveMatch]
WHERE [Id] = @Id

GO

/****** Object:  StoredProcedure [dbo].[CMS_LiveMatch_Update]    Script Date: 06/24/2012 00:50:32 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[CMS_LiveMatch_Update]
(
	@Id int,
	@Title nvarchar(200),
	@LinkLive ntext,
	@Avatar nvarchar(100)
)

AS

SET NOCOUNT ON

UPDATE [CMS_LiveMatch]
SET [Title] = @Title,
	[LinkLive] = @LinkLive,
	[Avatar] = @Avatar
WHERE [Id] = @Id

GO

/****** Object:  StoredProcedure [dbo].[CMS_LiveMatch_Insert]    Script Date: 06/24/2012 00:50:32 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[CMS_LiveMatch_Insert]
(
	@Title nvarchar(200),
	@LinkLive ntext,
	@Avatar nvarchar(100)
)

AS

SET NOCOUNT ON

INSERT INTO [CMS_LiveMatch]
(
	[Title],
	[LinkLive],
	[Avatar]
)
VALUES
(
	@Title,
	@LinkLive,
	@Avatar
)

DECLARE @id int set @id=SCOPE_IDENTITY()
SELECT @id

GO

/****** Object:  StoredProcedure [dbo].[CMS_Game_Select]    Script Date: 06/24/2012 00:50:32 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[CMS_Game_Select]
@Type INT,
@Para_1 NVARCHAR(100) = NULL,
@Para_2 NVARCHAR(100) = NULL
AS
BEGIN	
	IF(@Type = 1) 
		BEGIN
			SELECT  * 
			FROM	CMS_Game								
		END	
	IF(@Type = 2) 
		BEGIN
			SELECT * FROM CMS_Game
			WHERE IdGame = CAST(@Para_1 AS INT)						
		END		
			
END

GO

/****** Object:  StoredProcedure [dbo].[CMS_Game_Delete]    Script Date: 06/24/2012 00:50:32 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[CMS_Game_Delete]
(
	@IdGame int
)

AS

SET NOCOUNT ON

DELETE FROM [CMS_Game]
WHERE [IdGame] = @IdGame

GO

/****** Object:  StoredProcedure [dbo].[CMS_Game_Update]    Script Date: 06/24/2012 00:50:32 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[CMS_Game_Update]
(
	@IdGame int,
	@NameGame nvarchar(200),
	@CateId int,
	@Production nvarchar(200),
	@LinkGame nvarchar(200),
	@Avatar nvarchar(200),
	@CreatedOn datetime,
	@CreatedBy nvarchar(50),
	@Status int,
	@ShowType int,
	@Description nvarchar(1000),
	@Contents ntext
)

AS

SET NOCOUNT ON

UPDATE [CMS_Game]
SET [NameGame] = @NameGame,
	[CateId] = @CateId,
	[Production] = @Production,
	[LinkGame] = @LinkGame,
	[Avatar] = @Avatar,
	[CreatedOn] = @CreatedOn,
	[CreatedBy] = @CreatedBy,
	[Status] = @Status,
	[ShowType] = @ShowType,
	[Description] = @Description,
	[Contents] = @Contents
WHERE [IdGame] = @IdGame

GO

/****** Object:  StoredProcedure [dbo].[CMS_Game_Insert]    Script Date: 06/24/2012 00:50:32 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[CMS_Game_Insert]
(
	@NameGame nvarchar(200),
	@CateId int,
	@Production nvarchar(200),
	@LinkGame nvarchar(200),
	@Avatar nvarchar(200),
	@CreatedOn datetime,
	@CreatedBy nvarchar(50),
	@Status int,
	@ShowType int,
	@Description nvarchar(1000),
	@Contents ntext
)

AS

SET NOCOUNT ON

INSERT INTO [CMS_Game]
(
	[NameGame],
	[CateId],
	[Production],
	[LinkGame],
	[Avatar],
	[CreatedOn],
	[CreatedBy],
	[Status],
	[ShowType],
	[Description],
	[Contents]
)
VALUES
(
	@NameGame,
	@CateId,
	@Production,
	@LinkGame,
	@Avatar,
	@CreatedOn,
	@CreatedBy,
	@Status,
	@ShowType,
	@Description,
	@Contents
)

DECLARE @id int set @id=SCOPE_IDENTITY()
SELECT @id

GO


